<extend name="Public/base"/>

<block name="body">
    <div class="main-title">
        <h2>{$row['id']?'编辑':'新增'}用户</h2>
    </div>
    <form action="{:U('admin/studen/save')}" method="post" class="form-horizontal">
        <div class="form-item">
            <label class="item-label">用户姓名<span class="check-tips">*</span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="fullname" value="{$row.fullname}">

            </div>

        </div>
        <div class="form-item">
            <label class="item-label">性别<span class="check-tips">*</span></label>
            <div class="controls">
                
                <select name="sex" >
                    <option value=1 <if condition="$row.sex eq 1">selected</if> >男</option>
                    <option value=0 <if condition="$row.sex eq false">selected</if> >女</option>
                </select>

            </div>
        </div>
        <div class="form-item">
            <label class="item-label">年龄</label>
            <div class="controls">
                <select name="generation">
                    <?php foreach ($_generation as $key => $value): ?>
                        <option value="{$key}" <if condition="$key eq $row['generation']">selected</if> >
                        {$value} </option> 
                    <?php endforeach ?> 
                </select>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">所在学校</label>
            <div class="controls">
                <input type="text" class="text input-large" name="school" value="{$row.school}">

            </div>
        </div>
        <div class="form-item">
            <label class="item-label">所在班级</label>
            <div class="controls">
          
                <select name="grade">
                    <?php foreach ($_grade as $key => $value): ?>
                        <option value="{$key}" <if condition="$key eq $row['grade']">selected</if> >
                        {$value} </option> 
                    <?php endforeach ?>

                     
                </select>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">联系电话<span class="check-tips">*</span>(数据表唯一)</label>
            <div class="controls">
            <if condition="$row.id eq false ">
                 <input type="text" class="text input-large" name="telephone" value="{$row.telephone}">
            <else />
               
                <label>{$row.telephone}</label>
            </if>
     
            
            </div>
            <span class="phone_errmsg" style="color:red;display:none">联系电话已经被占用</span>
        </div>

        <div class="form-item">
            <label class="item-label">其它联系电话<span class="check-tips">多个电话请用;分隔</span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="contact_phone" value="{$row.contact_phone}">
            </div>
        </div>

        <div class="form-item">
            <label class="item-label">家长<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="parents" value="{$row.parents}">
            </div>
        </div>  
        
        <div class="form-item">
            <label class="item-label">家长身份<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="parents_appellative" value="{$row.parents_appellative}">
            </div>
        </div>  

        <div class="form-item">
            <label class="item-label">意向值<span class="check-tips"></span></label>
            <div class="controls">
                 
                 <select name="intention" >
                    <option value=0 <if condition="$row.intention eq false">checked</if> >0</option>
                    <option value=1 <if condition="$row.intention eq 1">checked</if> >1</option>
                    <option value=2 <if condition="$row.intention eq 2">checked</if> >2</option>
                    <option value=3 <if condition="$row.intention eq 3">checked</if> >3</option>
                    <option value=4 <if condition="$row.intention eq 4">checked</if> >4</option>
                    <option value=5 <if condition="$row.intention eq 5">checked</if> >5</option>
                </select>
            </div>
        </div> 

        <div class="form-item">
            <label class="item-label">是否报名<span class="check-tips"></span></label>
            <div class="controls">
                <select name="is_signup" >
                    <option value=0 <if condition="$row.is_signup eq false">checked</if> >否</option>
                    <option value=1 <if condition="$row.is_signup eq 1">checked</if> >是</option>
                   
                </select>
            </div>
        </div>

        
        <div class="form-item">
            <label class="item-label">家庭住址<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="homeaddress" value="{$row.homeaddress}">
            </div>
        </div>
<!--
        <div class="form-item">
            <label class="item-label">来源<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="source" value="">
            </div>
        </div>
-->        
        <div class="form-item">
            <label class="item-label">活动类型：<span class="check-tips"></span></label>
            <div class="controls">
                <select name="active_type" class="active_type">
                                <foreach name="select_active_type" item="item" key="key">
                                    <option value="{$key}" <if condition="$row.active_type eq $key">selected</if> >{$item}</option>
                                </foreach>
                            </select>
            </div>
        </div>

        <div class="form-item">
            <label class="item-label">是否有效记录<span class="check-tips"></span></label>
            <div class="controls">
                <select name="is_effective" class="is_effective" >
                    <option value=1  <if condition="$row.is_effective eq 1">selected</if> >是</option>
                    <option value=0 <if condition="$row.is_effective eq 0">selected</if> >否</option>
                </select>
            </div>
        </div>
    
        <div class="form-item invalid_memo" style="display:none">
            <label class="item-label">无效原因<span class="check-tips"></span></label>
            <div class="controls">
         
                <textarea class="text input-large" name="invalid_memo"></textarea>
            </div>
        </div>

          <div class="form-item">
            <label class="item-label">备注<span class="check-tips"></span></label>
            <div class="controls">
                <textarea name="remark">{$row.remark}</textarea>
            </div>
        </div>

         
        <div class="form-item">
            <if condition="$row.id neq false">
                <input type="hidden" name="id" value="{$row.id}">
            </if>
            
            <button class="btn submit-btn ajax-post" id="submit" type="submit" target-form="form-horizontal">确 定</button>
            <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
        </div>
    </form>
</block>

<block name="script">
    <script type="text/javascript">
        // Think.setValue("type", {$info.type|default=0});
        // Think.setValue("group", {$info.group|default=0});
        //导航高亮
        $('.side-sub-menu').find('a[href="{:U('User/index')}"]').closest('li').addClass('current');

        $(document).on("change",".is_effective",function(){
                _self = this;
                if (_self.value==0) {
                    $(".invalid_memo").show();
                } else {
                    $(".invalid_memo").hide();
                }
            })

        $(document).on("focus","input[name='telephone']",function(){
              $(".phone_errmsg").hide();  
        }

        $(document).on("blur","input[name='telephone']",function(){
            
            _telephone = this.value ;
            $.post("{:U('studen/getphone')}","telephone="+_telephone,function(res){
 
                if (res!='telephone_add_ok') {
                    $("#submit").attr("disabled",true);
                    $(".phone_errmsg").show();
                } else {
                    $("#submit").removeAttr("disabled");
                    $(".phone_errmsg").hide();
                }
            })

        })
    </script>
</block>

